package com.zds.service.impl;

import com.zds.dao.AccountDao;
import com.zds.dao.impl.AccountDaoImpl;
import com.zds.mapper.AccountMapper;
import com.zds.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @className:AccountServiceImpl
 * @date: 2024/12/24 下午8:46
 * @description:
 */
@Component("accountService")

public class AccountServiceImpl implements AccountService {
    @Autowired
    private AccountDao accountDao;
    @Autowired
    private AccountMapper accountMapper;
    @Override
    @Transactional()
    public void transfer(String from, String to, Integer amount) {
        accountMapper.updatedecr(from,amount);
//        int i = 1/0;
        accountMapper.updateincr(to,amount);
    }

    public void setAccountDao(AccountDaoImpl accountDao) {
        this.accountDao = accountDao;
    }
}
